import { defineStore } from 'pinia';
import zhCN from 'ant-design-vue/es/locale/zh_CN';
import defaultSetting from '@/config/default-setting';

export interface LayoutSetting {
  title: string;
  theme?: object;
  asideTheme: string;
  collapsed: boolean;
  locale?: typeof zhCN;
  colorPrimary?: string;
}

export const useAppStore = defineStore('app', {
  state: (): LayoutSetting => ({
    title: defaultSetting.title,
    theme: {
      token: {
        colorBgContainer: '#fff',
        colorPrimary: defaultSetting.colorPrimary,
      },
    },
    asideTheme: defaultSetting.asideTheme,
    collapsed: defaultSetting.collapsed,
    locale: zhCN,
  }),
  getters: {
    getTheme: (state) => state.theme,
    getLocale: (state) => state.locale,
  },
  actions: {
    updataCollapsed(status: boolean) {
      this.collapsed = status;
    },
  },
});
